﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using QuanLyBongDa.HeThongGiaoDien;
using QuanLyBongDa.HeThongLuuTru;
using QuanLyBongDa.HeThongXuLy;

namespace QuanLyBongDa.HeThongLuuTru
{
    class DanhSachCauThu
    {
        public static bool ThemCauThu(DanhSachCauThuDTO ds)
        {
            try
            {
                string sql = "insert into DANHSACHCAUTHU(TenCauThu, TenDoiBong, LoaiCauthu, ViTri, SoAo, QuocTich, TongSoBanThang) values ('" + ds.TenCauThu + "','" + ds.TenDoiBong + "','" + ds.LoaiCauThu + "','" + ds.ViTri + "'," + ds.SoAo + ",'" + ds.QuocTich + "'," + ds.TongSoBanThang + ")";
                DataAccess.ExecNonQuery(sql);
                return true;

            }
            catch (Exception)
            {
                //MessageBox.Show(ex.ToString());
                return false;
            }
        }
        public static DataTable BangDanhSachCauThu()
        {
            string sql = "SELECT* FROM DANHSACHCAUTHU";
            return DataAccess.ExecQuery(sql);
        }

        public static bool XoaCauThu(DanhSachCauThuDTO ds)
        {
            try
            {
                string sql = "Delete from DANHSACHCAUTHU where STT = " + ds.MaCauThu;
                DataAccess.ExecNonQuery(sql);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public static bool SuaDanhSachCauThu(DanhSachCauThuDTO ds)
        {
            try
            {
                string sql = " Update DANHSACHCAUTHU set TenCauThu = '" + ds.TenCauThu + "',TenDoiBong = '" + ds.TenDoiBong + "',LoaiCauthu = '" + ds.LoaiCauThu + "',ViTri = '" + ds.ViTri + "',SoAo = " + ds.SoAo + ",QuocTich = '" + ds.QuocTich + "',TongSoBanThang = " + ds.TongSoBanThang + "where STT=" + ds.MaCauThu;
                DataAccess.ExecNonQuery(sql);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

    }
}
